package com.googlecode.dgwt.client.dojo.data;

import java.util.Collection;

import com.googlecode.dgwt.client.dojo.data.base.IndexedStoreBase;


/**
 * @author      Wellington Tadeu dos Santos
 * @since       DGWT v0.01
 */
public class ListStore<Item> extends IndexedStoreBase<Item> {


    public ListStore() {
        super();
    }

    public ListStore(Collection<? extends Item> items) {
        super(items);
    }

    public ListStore(int initialCapacity) {
        super(initialCapacity);
    }
    
    protected ListStore(ListStore<Item> mirroredStore) {
        super(mirroredStore);
    }

    
    @Override
    public Object getValue(Item item, int columnIndex) {
        return item;
    }

    @Override
    @SuppressWarnings("unchecked")
    public boolean setValue(Item item, int columnIndex, Object value) {
        if (!isReadOnly()) {
            this.set(indexOf(item), (Item) value);
            return true;
        }
        return false;
    }

    @Override
    public ListStore<Item> createMirror() {
        return new ListStore<Item>(this);
    }

    @Override
    public void setReadOnly(boolean readOnly) {
        super.setReadOnly(readOnly);
    }

}
